package com.song.service.impl;

import com.song.dao.StudentDao;
import com.song.pojo.Student;
import com.song.service.StudentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2024/1/15
 * @Version 1.0
 **/
@Service
public class StudentServiceImpl implements StudentService {
    @Resource
    private StudentDao studentDao;

//   public StudentServiceImpl(StudentDao studentDao){
//       this.studentDao=studentDao;
//   }
    @Override
    public List<Student> findAll() {
        return this.studentDao.findAll();
    }

    @Override
    public Student findById(Integer id) {
        return (Student) this.studentDao.findAllById(Collections.singleton(id));
    }

    @Override
    public void add(Student student) {
          this.studentDao.save(student);
    }
}
